//
//  UIBarButtonItem+Util.m
//  Weibo
//
//  Created by 千锋 on 15/12/30.
//  Copyright © 2015年 abc. All rights reserved.
//

#import "UIBarButtonItem+Util.h"

@implementation UIBarButtonItem (Util)


//通过传入图片名称创建barButtonItem
+ (UIBarButtonItem *)generateBarButtonItemWithNormaImageName:(NSString*)norImgName highlightedImageName:(NSString*)hlImgName{
    
    //1. 创建一个按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:norImgName] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:hlImgName] forState:UIControlStateHighlighted];
    
    CGSize size = button.currentImage.size;
    button.frame = CGRectMake(0, 0, size.width, size.height);
    //2. 创建barButtonItem 返回
    UIBarButtonItem * item = [[UIBarButtonItem alloc]initWithCustomView:button];
    return item;
}
@end
